<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/page/share/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<title>添加人员</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="/css/modules.css" type="text/css"
			media="screen" />
		<link rel="stylesheet" href="/css/modules1.css" type="text/css"
			media="screen" />
		<style type="text/css">
		label{
			display:inline;
		}
		</style>
		<script type="text/javascript" src="/js/FoshanRen.js"></script>
		<script type="text/javascript" src="/js/xmlhttp.js"></script>
		<script type="text/javascript" src="/js/jquery-1.4.2.min.js" ></script>
		<script type="text/javascript">
		
		$(function(){
			$("#provincespan").load("/area/province!getProvince.action");
		});
		function loadCity(f){
				var provinceid=$(f).val();
				$("#cityspan").load("/area/province!getCity.action?provinceid='"+provinceid+"'");
				$("#regionspan").html("");
				$(f).attr("name","province.id");
		}
		
		function loadRegion(f){
			var cityid=$(f).val();
			$("#regionspan").load("/area/province!getRegion.action?cityid='"+cityid+"'");
			$("#psel").attr("name","");
			$(f).attr("name","province.id");
		//	$("#csel").attr("name","");
		}

		function zz(f){
			
			$("#csel").attr("name","");
			$(f).attr("name","province.id");
		//	$("#csel").attr("name","");
		}
		
		
function validateUsernameExsit(username){
	if(username.trim()!=""){
		var usernameview = document.getElementById('usernameview');		
		if(usernameview){
			send_request(function(value){usernameview.innerHTML=value},
					 '<s:url action="UserManage!exist"/>?phone='+ username, true);
		}
	}
}

function Formfield(name, label){
	this.name=name;
	this.label=label;
}
function checkfm(form){
	
	var list  = new Array(new Formfield("realname", "真实姓名"),new Formfield("idCard", "身份证号码"),
				new Formfield("postalcode","邮编"),new Formfield("phone", "联系电话"),
				new Formfield("email","电子邮件"));
	for(var i=0;i<list.length;i++){
		var objfield = eval("form."+ list[i].name);
		if(trim(objfield.value)==""){
			alert(list[i].label+ "不能为空");
			if(objfield.type!="hidden" && objfield.focus()) objfield.focus();
			return false;
		}
	}
	if(form.username.value.length<6){
		alert("登录账号的长度应大于或等于6位");
		return false;
	}
	if(form.password.value.length<6){
		alert("密码的长度应大于或等于6位");
		return false;
	}
	if(form.password.value!=form.password2.value){
		alert("您两次输入的密码不一致");
		return false;
	}
	return true;
}
function validate(f){
	if(f.phone.value.length!=11){
		alert("请输入正确的手机号码!");
		return false;
	}
	return true;
}


</script>

	</head>
	<body style="background-color:transparent">
	<h2 class="jquery_tab_title">添加人员</h2>
	<div style="padding-top:20px;">
		<s:form action="UserManage!addUser" method="post" onsubmit="return validate(this)" theme="simple">
			 <s:token />
			<table width="90%" border="0" cellspacing="0" cellpadding="0" id="noborder_table">
				<tr>
				 	<td align="center">手机号码<span style="color:red">*</span></td>
				 	<td><s:textfield cssClass="input-small" maxlength="11" name="phone" onblur="javascript:validateUsernameExsit(this.value)"></s:textfield>(作为登录账号,密码默认为手机号后8位)<div id="usernameview"></div></td>
				</tr>
				<tr>
				 	<td align="center">真实姓名<span style="color:red">*</span></td>
				 	<td><s:textfield cssClass="input-small" name="realname"  theme="simple" size="10" maxlength="10"></s:textfield></td>
				</tr>	
					
				<tr>
				 	<td align="center">性别<span style="color:red">*</span></td>
				 	<td><s:radio list="%{#{'MAN':'男','WOMAN':'女'}}" name="gender"
					value="'MAN'"></s:radio></td>
				</tr>
				<tr>
				 	<td align="center">选择角色<span style="color:red">*</span></td>
				 	<td>
				 	
				 	
					<s:if test="#session.user.role.name=='系统管理员'">
				 	<s:radio  id="roleRadio" list="%{#{'ADMIN':'系统管理员'}}"name="role" theme="simple" ></s:radio>
					</s:if>
					</td>
				</tr>		
				<tr>
				 	<td align="center">部门</td>
				 	<td>
				 	<select name="departmentid" id="departmentid" >
			            <c:forEach items="${departments}" var="department">      
							<option value="${department.id}">${department.name}</option> 
					    </c:forEach>	            
            		</select>
            		</td>
				</tr>	
				<tr>
				 	<td align="center">电子邮箱</td>
				 	<td><s:textfield cssClass="input-medium" name="email"  theme="simple" size="10"></s:textfield></td>
				</tr>	
				
				<tr>
					<td></td>
					<td>
						<input type="submit" name="SYS_SET" value=" 确 定 添 加 " class="button" />
					</td>
				</tr>
			</table>
		</s:form>
		</div>
	</body>
</html>